//
//  PersonalPickerView.m
//  UHealth
//
//  Created by hanyou on 3/24/15.
//  Copyright (c) 2015 gjtx. All rights reserved.
//

#import "PersonalPickerView.h"

@implementation PersonalPickerView

+ (instancetype)pickerView {
    
    return [[PersonalPickerView alloc] init];
}


- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        [self setupView];
    }
    return self;
}

- (void)setupView {
    UIView *conView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 216)];
    conView.backgroundColor = [UIColor redColor];
    [self addSubview:conView];
    
    UIButton *doneButton  = [[UIButton alloc] init];
    CGFloat width = 100;
    doneButton.frame = CGRectMake(kScreenWidth-width, 0, width, 35);
    [doneButton setTitle:@"确定" forState:UIControlStateNormal];
    [doneButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [doneButton addTarget:self action:@selector(buttonOnClicked:) forControlEvents:UIControlEventTouchUpInside];
    doneButton.backgroundColor = [UIColor grayColor];
    [self addSubview:doneButton];
    
    self.userInteractionEnabled = YES;
    
    [self addSubview:[UISwitch new]];
}

- (void)buttonOnClicked:(UIButton *)sender {
    CGRect  frame = self.frame;
    
    if (frame.origin.y == kScreenHeight-216) {
        frame.origin.y = kScreenHeight;
        [UIView animateWithDuration:0.5 animations:^{
            self.frame = frame;
        }];
    }
    
    if (self.completion) {
        self.completion();
    }
    
}
@end
